home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kdesu / ssh.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  2.1 KB  |  91 lines

  1. /* vi: ts=8 sts=4 sw=4
  2.  *
  3.  * $Id: ssh.h 433124 2005-07-09 19:01:03Z adridg $
  4.  *
  5.  * This file is part of the KDE project, module kdesu.
  6.  * Copyright (C) 2000 Geert Jansen <jansen@kde.org>
  7.  * 
  8.  * This is free software; you can use this library under the GNU Library 
  9.  * General Public License, version 2. See the file "COPYING.LIB" for the 
  10.  * exact licensing terms.
  11.  */
  12.  
  13. #ifndef __SSH_h_Included__
  14. #define __SSH_h_Included__
  15.  
  16. #include <qcstring.h>
  17.  
  18. #include "stub.h"
  19.  
  20. #include <kdelibs_export.h>
  21.  
  22. /**
  23.  * Executes a remote command, using ssh.
  24.  */
  25.  
  26. class KDESU_EXPORT SshProcess: public StubProcess
  27. {
  28. public:
  29.     SshProcess(const QCString &host=0, const QCString &user=0, const QCString &command=0);
  30.     ~SshProcess();
  31.  
  32.     enum Errors { SshNotFound=1, SshNeedsPassword, SshIncorrectPassword };
  33.  
  34.     /**
  35.      * Sets the target host.
  36.      */
  37.     void setHost(const QCString &host) { m_Host = host; }
  38.  
  39.     /**
  40.      * Sets the localtion of the remote stub.
  41.      */
  42.     void setStub(const QCString &stub);
  43.  
  44.     /** 
  45.      * Checks if the current user\@host needs a password. 
  46.      * @return The prompt for the password if a password is required. A null
  47.      * string otherwise.
  48.      *
  49.      * @todo The return doc is so obviously wrong that the C code needs to be checked.
  50.      */
  51.     int checkNeedPassword();
  52.  
  53.     /**
  54.      * Checks if the stub is installed and if the password is correct.
  55.      * @return Zero if everything is correct, nonzero otherwise.
  56.      */
  57.     int checkInstall(const char *password);
  58.  
  59.     /**
  60.      * Executes the command.
  61.      */
  62.     int exec(const char *password, int check=0);
  63.  
  64.     QCString prompt() { return m_Prompt; }
  65.     QCString error() { return m_Error; }
  66.  
  67. protected:
  68.     virtual QCString display();
  69.     virtual QCString displayAuth();
  70.     virtual QCString dcopServer();
  71.  
  72. private:
  73.     QCString dcopForward();
  74.     int ConverseSsh(const char *password, int check);
  75.  
  76.     int m_dcopPort;
  77.     int  m_dcopSrv;
  78.     QCString m_Prompt;
  79.     QCString m_Host;
  80.     QCString m_Error;
  81.     QCString m_Stub;
  82.  
  83. protected:
  84.     virtual void virtual_hook( int id, void* data );
  85. private:
  86.     class SshProcessPrivate;
  87.     SshProcessPrivate *d;
  88. };
  89.  
  90. #endif
  91.